package com.jing.android.notes.ui.widget;

import android.content.Context;
import android.util.AttributeSet;
import android.util.Log;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.widget.NestedScrollView;

public class NestedScrollViewV2 extends NestedScrollView {

    private static final String TAG = NestedScrollViewV2.class.getSimpleName();

    public NestedScrollViewV2(@NonNull Context context) {
        super(context);
    }

    public NestedScrollViewV2(@NonNull Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
    }

    public NestedScrollViewV2(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @Override
    public boolean dispatchNestedPreScroll(int dx, int dy, int[] consumed, int[] offsetInWindow, int type) {
        boolean flag = super.dispatchNestedPreScroll(dx, dy, consumed, offsetInWindow, type);
        Log.i(TAG, "dispatchNestedPreScroll param: dy: " + dy + ", consumedY: " + (consumed == null ? 0 : consumed[1]) +
                ", offsetInWindowY: " + (offsetInWindow == null ? 0 : offsetInWindow[1]) + ", type: " + type +  "; super return: " + flag);
        return flag;
    }

    @Override
    public void dispatchNestedScroll(int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed, @Nullable int[] offsetInWindow, int type, @NonNull int[] consumed) {
        super.dispatchNestedScroll(dxConsumed, dyConsumed, dxUnconsumed, dyUnconsumed, offsetInWindow, type, consumed);
        Log.i(TAG, "dispatchNestedScroll param: dyConsumed: " + dyConsumed + ", dyUnconsumed: " + dyUnconsumed +
                ", offsetInWindowY: " + (offsetInWindow == null ? 0 : offsetInWindow[1]) + ", type: " + type + ", consumedY: " + (consumed == null ? 0 : consumed[1]));
    }
}
